<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>
        <ui:composition template="/templates/default.xhtml">
            <ui:define name="content">
                <h:form>
                    <h:commandButton value="#{locale.buttonNewDepartment}" action="#{newDepartment.addNewDepartment}" />
                    <p/>
                    <h:dataTable value="#{departmentList.departments}" var="dep" >
                        <h:column>
                            <f:facet name="header">
                                #{locale.dtHeaderName}
                            </f:facet>
                            <h:inputText value="#{dep.name}" size="10" rendered="#{dep.editable}" />
                            <h:outputText value="#{dep.name}" rendered="#{not dep.editable}" />
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                #{locale.dtHeaderAddress}
                            </f:facet>
                            <h:inputText value="#{dep.address}" size="20" rendered="#{inst.editable}" />
                            <h:outputText value="#{dep.address}" rendered="#{not inst.editable}" />
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                #{locale.dtHeaderPhone}
                            </f:facet>
                            <h:inputText value="#{dep.phoneNr}" size="10" rendered="#{dep.editable}" />
                            <h:outputText value="#{dep.phoneNr}" rendered="#{not dep.editable}" />
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                #{locale.dtHeaderNote}
                            </f:facet>
                            <h:inputText value="#{dep.note}" size="30" rendered="#{dep.editable}" />
                            <h:outputText value="#{dep.note}" rendered="#{not dep.editable}" />
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                #{locale.dtHeaderInstitute}
                            </f:facet>
                            <h:inputText value="#{dep.institute.name}" size="30" rendered="#{dep.editable}" />
                            <h:outputText value="#{dep.institute.name}" rendered="#{not dep.editable}" />
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                #{locale.dtHeaderEdit}
                            </f:facet>
                            <h:commandButton value="#{locale.buttonEdit}" action="#{dep.setEditable(true)}" rendered="#{not dep.editable}" />
                            <h:commandButton value="#{locale.buttonSave}" action="#{departmentList.executeChanges}" rendered="#{dep.editable}" />
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                #{locale.dtHeaderDelete}
                            </f:facet>
                            <h:commandButton value="#{locale.buttonDelete}" action="#{departmentList.setDeleteFlagAndNavigate(dep)}" />
                        </h:column>
                    </h:dataTable>
                 </h:form>
             </ui:define>
         </ui:composition>
    </h:body>
</html>

